<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>编辑客户信息</title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
    />
    <link rel="stylesheet" href="../js/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="../style/admin.css" media="all"/>
    <link rel="stylesheet" href="../style/home.css" media="all"/>
    <script src="../js/layui/layui.js"></script>
    <style>
        .layui-form-item .layui-inline {
            padding-right: 0px;
            margin-right: 0px;
        }

        html,
        body {
            background-color: #fff;
            width: 100%;
            height: 100%;
            margin: 0px;
            padding: 0px;
            border: 0px;
        }
    </style>
</head>
<body layadmin-themealias="default">
<div class="" style="padding: 20px;">
    <div class="layui-row layui-col-space15">
        <div class="layui-card pr20" style=" height: 440px">
            <form class="layui-form" lay-filter="postData" action="" id="postData">
                <input type="hidden" name="id" value="put" th:value="${data.id}"/>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">客户编号</label>
                    <div class="layui-input-block">
                        <input type="text" name="code" placeholder="请输入客户编号"
                               autocomplete="off" class="layui-input" required lay-verify="required"
                               th:value="${data.code}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">客户身份</label>
                    <div class="layui-input-block">
                        <input type="text" name="customerIdentity" placeholder="请输入客户身份"
                               autocomplete="off" class="layui-input"
                               th:value="${data.customerIdentity}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs12">
                    <label class="layui-form-label">客户名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" placeholder="请输入客户名称"
                               autocomplete="off" class="layui-input" required lay-verify="required"
                               th:value="${data.name}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs12">
                    <label class="layui-form-label">用电地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="premiseAddress" placeholder="请输入用电地址"
                               autocomplete="off" class="layui-input"
                               th:value="${data.premiseAddress}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">供电单位</label>
                    <div class="layui-input-block">
                        <input type="text" name="powerSupplier" placeholder="请输入供电单位"
                               autocomplete="off" class="layui-input"
                               th:value="${data.powerSupplier}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">台区名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="districtName" placeholder="请输入台区名称"
                               autocomplete="off" class="layui-input"
                               th:value="${data.districtName}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs12">
                    <label class="layui-form-label">通邮地址</label>
                    <div class="layui-input-block">
                        <input type="text" name="postAddress" placeholder="请输入用电地址"
                               autocomplete="off" class="layui-input"
                               th:value="${data.postAddress}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">邮政编码</label>
                    <div class="layui-input-block">
                        <input type="text" name="postCode" placeholder="请输入邮政编码"
                               autocomplete="off" class="layui-input"
                               th:value="${data.postCode}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">传真</label>
                    <div class="layui-input-block">
                        <input type="text" name="fax" placeholder="请输入传真号码"
                               autocomplete="off" class="layui-input"
                               th:value="${data.fax}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs12">
                    <label class="layui-form-label">电子邮箱</label>
                    <div class="layui-input-block">
                        <input type="text" name="email" placeholder="请输入电子邮箱"
                               autocomplete="off" class="layui-input"
                               th:value="${data.email}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs12">
                    <label class="layui-form-label">证件号</label>
                    <div class="layui-input-block">
                        <input type="text" name="idNumber" placeholder="请输入客户证件号"
                               autocomplete="off" class="layui-input"
                               th:value="${data.idNumber}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-block">
                        <input type="text" name="contact" placeholder="请输入联系人"
                               autocomplete="off" class="layui-input"
                               th:value="${data.contact}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">联系电话</label>
                    <div class="layui-input-block">
                        <input type="text" name="contactPhone" placeholder="请输入联系电话"
                               autocomplete="off" class="layui-input"
                               th:value="${data.contactPhone}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">用电类别</label>
                    <div class="layui-input-block">
                        <input type="text" name="category" placeholder="请输入用电类别"
                               autocomplete="off" class="layui-input"
                               th:value="${data.category}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">用电性质</label>
                    <div class="layui-input-block">
                        <input type="text" name="usageNature" placeholder="请输入用电性质"
                               autocomplete="off" class="layui-input"
                               th:value="${data.usageNature}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">结算账号</label>
                    <div class="layui-input-block">
                        <input type="text" name="accountNumber" placeholder="请输入结算账号"
                               autocomplete="off" class="layui-input"
                               th:value="${data.accountNumber}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs6">
                    <label class="layui-form-label">供电电压</label>
                    <div class="layui-input-block">
                        <input type="text" name="supplyVoltage" placeholder="请输入供电电压"
                               autocomplete="off" class="layui-input"
                               th:value="${data.supplyVoltage}"
                        />
                    </div>
                </div>
                <div class="layui-col-xs12">
                    <label class="layui-form-label">备注</label>
                    <div class="layui-input-block">
                        <input type="text" name="remarks" autocomplete="off" class="layui-input"
                               th:value="${data.remarks}"
                        />
                    </div>
                </div>
                <button type="submit" class="layui-btn" lay-submit="" lay-filter="postData"
                        id="postBut" style="display: none">
                    保存
                </button>
            </form>
        </div>
    </div>
</div>
<script>
    var callBackReturn = false;
    var index = parent.layer.getFrameIndex(window.name);
    layui.use(['laydate', 'form'], function () {
        var $ = layui.$, form = layui.form;
        form.render();


        form.on('submit(postData)', function (obj) {
            var data = obj.field;
            $.ajax({
                url: './saveCustomerInfo', //url
                contentType: "application/json",
                dataType: 'json', //数据格式
                type: 'POST', //请求方式
                async: false, //是否异步请求
                data: JSON.stringify(data),
                success: function (result) {
                    if (result.code == 0) {
                        parent.layer.msg(result.message, {icon: 1});
                        callBackReturn = true;
                        parent.layer.close(index);
                    } else {
                        parent.layer.alert(result.message, {icon: 2});
                    }
                },
            });
            return false;
        });
    });


    function Submit() {
        document.getElementById('postBut').click();
        return callBackReturn;
    }
</script>
<script type="text/javascript" src="../js/lib/watermark.js"></script>
</body>
</html>
